<?php  
	include("../includes/connection.php");
	$code = $_POST['code'];
	$act = $_POST['act'];
	$sql = "SELECT * FROM tb_portfolio_image where code = '$code'";
	$query = mysql_query($sql);
	while ($result = mysql_fetch_array($query)) {
		$is_default = 0;
    $show_default = "";
		if ($act == "edit") {
			$sql_portfolio = "SELECT * FROM tb_portfolio WHERE code = '$code'";
			$query_portfolio = mysql_query($sql_portfolio);
			$result_portfolio = mysql_fetch_array($query_portfolio);
	    if ($result["gambar"] == $result_portfolio["gambar"]) {
	      $is_default = 1;
	      $show_default = "style='display: block;'";
	    }
		}
?>
	<div class="img-tile-placer">
		<div class="img-tile">
			<div class="div">
				<img src="../img/portfolio/<?php echo $result['code'] ?>/<?php echo $result['gambar'] ?>" alt="../img/portfolio/<?php echo $result['code'] ?>/<?php echo $result['gambar'] ?>">
			</div>
			<div class="image-default" <?php echo $show_default; ?>>
				<div>Default</div>
			</div>
			<input type="hidden" class="is_default" value="<?php echo $is_default ?>">
			<input type="hidden" class="img_name" value="<?php echo $result['gambar'] ?>">
			<input type="hidden" class="id_portfolio_image" value="<?php echo $result['id'] ?>">
		</div>
		
		<div class="del-image">
			<i class="glyphicon glyphicon-trash"></i>Hapus
		</div>
	</div>
<?php
	}
?>
<div style="clear: both;"></div>